#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
    pid_t id = fork();
    if(id == 0) //子进程
    {
        int cnt = 5;
        while(1)
        {
            printf("我是子进程:%d\n",getpid());
            sleep(1);
        }
        printf("子进程已退出\n");
        exit(1);
    }
    //父进程
    int cnt = 5;
    while(cnt--)
    {
        printf("我是父进程,pid:%d\n",getpid());
        sleep(1);
    }
    printf("父进程退出\n");
    return 0;
}

//验证孤儿进程
//while :; do ps ajx | head -1 && ps ajx | grep myfork; sleep 1; done
